package com.jair.crawler.tiger;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;

import okhttp3.*;
/**
 * 老虎证券
 * @author wenjie
 *
 */
public class demo1 {

		 public static void main(String[] args) throws IOException {
			    //OkHttpClient client = new OkHttpClient();
			 
			 OkHttpClient okHttpClient = new demo2().getOkHttpClientBuilfer()
		                .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.236.103.66", 8888)))
		                .build();

			    Request request = new Request.Builder()
			            .url("https://hq1.itiger.com/astock/symbol/meta/600519")
			            .header("User-Agent", "okhttp/3.6.0")
			            .header("Authorization","Bearer xw38v0jXC9b6u6UDrMfvUIBZYXjQlC")
			            .build();
			 
			    Response response = okHttpClient.newCall(request).execute();
			    if (!response.isSuccessful()) {
			        throw new IOException("服务器端错误: " + response);
			    }
			    
			    System.out.println(response.header("Server"));
			    System.out.println(response.message());
			    System.out.println(response.headers("Set-Cookie"));
			   }

}
